{extend name="public/base"/}
{block name="body"}
<title>列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 数据管理 <span class="c-gray en">&gt;</span> 备份列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
    </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
            <tr>
                <th scope="col" colspan="9">数据列表<span class="r">共有数据：<strong>{$statistics.count}</strong> 条，共计：<strong>{$statistics.total}</strong></span></th>
            </tr>
            <tr class="text-c">
                <th width="100">文件名称</th>
                <th width="50">文件大小</th>
                <th width="130">备份时间</th>
                <th width="100">操作</th>
            </tr>
        </thead>
        <tbody>
            {volist name='list' id='list' empty="$empty"}
            <tr class="text-c">
                <td>{$list.name}</td>
                <td>{$list.size}</td>
                <td>{$list.addtime}</td>
                <td>
                    <a title="恢复" class="ml-5 btn btn-flat btn-primary btn-xs" data-time="{$list.time}" href="javascript:;" onclick="importup(this,{$list.time},{$list.sizes})">
                        <i class="Hui-iconfont">&#xe684;</i>恢复
                    </a>
                    <a title="下载" class="ml-5 btn btn-flat btn-sucess btn-xs"
                       href="{:url('downFile',['time'=>$list.time])}">
                        <i class="Hui-iconfont">&#xe640;</i>下载
                    </a>
                    <a title="删除" href="javascript:;" data-time="{$list.time}" onclick="delSql(this,{$list.time})" class="ml-5 btn btn-flat btn-danger btn-xs" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6e2;</i>删除
                    </a>
                </td>
            </tr>
            {/volist}
        </tbody>
    </table>
</div>
<script>
function delSql(obj,time){
    layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'delSqlFiles',
            data:{time:time},
            success: function(data){
                $(obj).parents("tr").remove();
                layer.msg('已删除!',{icon:1,time:3000});
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
}
function importup(obj,time,sizes){
    if(sizes<2097152){
        layer.confirm('确认要恢复数据库吗？',function(index){
            layer.load(1, {
              shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            $.ajax({
                type: 'POST',
                url: 'import',
                data:{time:time},
                success: function(data){
                    layer.msg('已恢复!',{icon:1,time:3000});
                    setTimeout("location.reload()",3000);
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });     
        });
    }else{
        layer.confirm('数据太大，建议让专业技术人员另行导入',function(index){
              setTimeout("location.reload()",1000);
        });
    }
    
}
</script>

{/block}